<?
require_once('config.php');
if(!isset($_SESSION["userlogin"])){
  redirect('login.php');  
}
?>
<!DOCTYPE HTML>
<head>
	<meta http-equiv="content-type" content="text/html" />
	<meta name="author" content="lovemoon" charset="UTF-8"/>
   <?=$css_global?>
   <?=$js_global?>
	<title>HỆ THỐNG QUẢN TRỊ CMS</title>
</head>

<body>

<div id="wraper">
   <?
   include_once('model/mod_header.php');
   ?>
   <div id="menu">
   <?
      include_once('model/mod_menu.php');
   ?>  
   </div>
   <div id="content">
      <div class="breadLine">
         <ul class="breadcrumb">
             <li><a href="#">Quản lý category</a> <span class="divider">&gt;</span></li>                
             <li class="active">Danh sách</li>
         </ul>
      </div>
      <div class="workplace">
         <div id="main-content"> <!-- Main Content Section with everything -->
   			<div id="RightPane" class="ui-layout-center ui-helper-reset ui-widget-content" ><!-- Tabs pane -->
               	<div id="tabs" class="jqgtabs">
                       <div class="content-box-header">
                   		<ul class="content-box-tabs tab_admin">
                   			<li class="ui-state-default ui-corner-top">
                              <a class="default-tab current"  style="" >Giới Thiệu</a>
                           </li>
                   		</ul>
                           <div id="tabs-1" class="bo_hidden bo_show" style="font-size:12px;" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
                   			<iframe id="idframe_0" src="intro.php" frameborder="0" width="100%" onresize="calcHeight('idframe_0');" onLoad=calcHeight('idframe_0');></iframe>
                   		</div>
                       </div>
               		
               	</div>
           	</div> <!-- #RightPane -->
   		</div> <!-- End #main-content -->
      </div>
   </div>
</div>
</body>
</html>
<script language="JavaScript">
function calcHeight(id)
{

	var dodai_trang = document.getElementById(id).contentWindow.document.body.scrollHeight;
	var hei = $(document).height() - $(".ui-layout-north").height() - 20;
	dodai_trang = dodai_trang + 50;
	dodai_trang = (dodai_trang < hei) ? hei : dodai_trang; 
	$("#"+id).height(dodai_trang);
}
</script>
<script>
    $('.add_tab').live('click',function(){
        $this = $(this);
        var id = $this.attr('id');
        var tit_tab = $this.attr('tit_nav');
        var url_tab = $this.attr('url_tab');
        var numbe   = $this.find('span').text();
        
        //$this.attr('statu') = statu+1;
        //numbe = numbe + 1
        //alert(numbe);
        //nếu = 0 thì tạo tab. lớn hơn 0 load lại tab
        if(numbe == 0){
            $this.find('span').text('1');
            //xóa active
            $('li').removeClass('ui-state-active');
            var tab = '<li id="litab_'+id+'" class="ui-state-default ui-state-active"><a id_tab="#tab_'+id+'"><span><span stt="'+id+'" class="relo reload_hide" title="Reload Tab"></span>'+tit_tab+'</span></a><span stt_clo="'+id+'" class="ui-tabs-close ui-icon ui-icon-close" title="Close Tab"></span></li>';
            $('.content-box-header').closest('.content-box-header').find('ul').append(tab);
            
            //xoa class bo_hidden
            $('.bo_hidden').removeClass('bo_show');
            var box_content = '<div id="tab_'+id+'" class="bo_hidden bo_show"><iframe id="idframe_'+id+'" src="'+url_tab+'" frameborder="0" style="height: 630px !important;" width="100%"></iframe></div>';
            
            //alert(box_content);
            //add box iframe
            $('.content-box-header').append(box_content);
        //nếu lớn hơn 0 load lại tab. và chuyển tab đó sang dạng active
        }else{
            //load lại tab
            document.getElementById('idframe_'+id).src = document.getElementById('idframe_'+id).src;
            //show tab đó lên
            $('.ui-state-default').removeClass('ui-state-active');
            $('#litab_'+id).addClass('ui-state-active');
            //show box content lên
            //var id_box = $this.find('a').attr('id_tab');
            $('.bo_hidden').removeClass('bo_show');
            $('#tab_'+id).addClass('bo_show');
        }
        
    });
    
    //load lại nội dung box content
    $(".relo").live("click",function(){
        //alert('ss');
        $this = $(this);
		var txt = $this.attr('stt');
        //alert('idframe_'+txt);
        document.getElementById('idframe_'+txt).src = document.getElementById('idframe_'+txt).src;
	});	
    //chuyển sang tab và box content đc chọn            
    $('.ui-state-default').live("click",function(){
       $this = $(this);
       //alert('sas'); 
       //hien tab tuong ung
       $('.ui-state-default').removeClass('ui-state-active');
       $(this).addClass('ui-state-active');
       //show box content
       var id_box = $this.find('a').attr('id_tab');
       $('.bo_hidden').removeClass('bo_show');
       $(id_box).addClass('bo_show');
       //alert(id_box);
    });
    
    //đóng tab và box content
    $('.ui-icon-close').live("click",function(){
       //alert('asa');
       $this = $(this);
       var stt = $(this).attr('stt_clo');
       var rem_tab = $this.closest('li').find('a').attr('id_tab');
       $(rem_tab).addClass('bo_hidden');
       $this.closest('li').remove();
       
       //set gia tri ve 0 để cho phép tạo lại tab
       $('#numbe_'+stt).text('0');
    });
    
</script>